let arr = [{name:'csc',age:18},{name:'hhh',age:18},{name:'lyz',age:19}]

Array.prototype.myfilter = function(callback) {
    let res = []
    for(let i = 0; i < this.length; i++) {
        if(callback(this[i], i, this)) {
            res.push(this[i])
        }
    }
    return res
}

let a = arr.myfilter(item => item.age <= 18)
console.log(a);